import api from "../../api/index.js";

const state={
    productDetail:{}
};

const mutations={
    setProductDetail(state,nv){
        state.productDetail=nv;
    }
};

const actions={
    loadProductDetail({commit},id){
        api.loadDetailProduct({
            type:1,
            itemId:id,
            appPlat:"m"
        }).then((data)=>{
            if(!data.success){
                return Promise.reject("网络错误!");
            };
            commit("setProductDetail",data.data||{})
        }).catch(api.showError);
    }
};

export default {
    state,
    mutations,
    actions
}